#define _CRT_SECURE_NO_WARNINGS
#include <iostream>

using namespace std;

string longestPalindrome(string s) {
    int n = s.size();
    int begin = 0, len = 1;
    for (int i = 0; i < n; ++i)
    {
        int left = i, right = i;
        while (left >= 0 && right < n && s[left] == s[right])
        {
            if (len <= right - left + 1)
            {
                begin = left;
                len = right - left + 1;
            }
            ++right;
            --left;
        }

        left = i, right = i + 1;
        while (left >= 0 && right < n && s[left] == s[right])
        {
            if (len <= right - left + 1)
            {
                begin = left;
                len = right - left + 1;
            }
            ++right;
            --left;
        }

    }

    return s.substr(begin, len);
}

int main()
{
    longestPalindrome("bb");
	return 0;
}